<%@ page contentType="text/html;charset=UTF-8" %> 
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<c:if test="${duty.editFlag == 1}">
               <title><spring:message code="duty_edit_create"/><spring:message code="duty_edit_edit"/></title>
    </c:if>
    <c:if test="${duty.editFlag == 0 }">
               <title><spring:message code="duty_edit_view" /><spring:message code="duty_edit_ok" /></title>
    </c:if>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
   
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    
    
    <script type="text/javascript">
    

	 $(document).ready(function(){
		 var form = $("#inputForm");  
	        form.validate();//验证指定的表单	    
	        if ('${duty.editFlag == 0}') {
       			$('.showHtml').find('input,radio,textarea').attr('disabled',true);
			}
	        	$("#okButton").click(function(){
	        		if (form.valid()) {//如果表单验证成功，则进行提交。  
	        		$("#showHtml").addClass("showHtml");
	                $("#okHead").css("display","block");
	                $("#createHead").css("display","none");     
	                $("#numCount").css("display","none");
	                $('.showHtml').find('input,radio,textarea').attr('disabled',true);
	                return false
	              }
	         });	        	 
	    });
	 
       
    /* 保存职务信息 */
    function saveForm(){
    	$('.showHtml').find('input,radio,textarea').attr('disabled',false);
    	var params = $("#inputForm").serialize();
    	$.post("${ctx}/business/install/dutySave",params,function(result){
    		/* 弹出提示框,刷新父页面,关闭当前页面 */
    		tipParent(result.message);
    		 window.parent.frames[0].searchListForm();
    	closeWin();
    		 
	
    	},'json');
    }
    /* 删除职务信息 */
    function deleteDuty(){
    	if (confirm("<spring:message code="duty_edit_areYouSure"/>")) {
    		$('.showHtml').find('input').removeAttr('disabled');
    		var params = $("#inputForm").serialize();
    		$.post("${ctx}/business/install/deleteDuty",params,function(result){
    			/* 弹出提示框,刷新父页面,关闭当前页面 */
    			tipParent(result.message);
    			 window.parent.frames[0].searchListForm();
    	  	  closeWin();
	
    		},'json');
		}
    }
    
    function textCounter(field, countfield, maxlimit) { 
    	   // 函数，3个参数，表单名字，表单域元素名，限制字符； 
    	   if (field.value.length > maxlimit) 
    	   //如果元素区字符数大于最大字符数，按照最大字符数截断； 
    	   field.value = field.value.substring(0, maxlimit); 
    	   else 
    	   //在记数区文本框内显示剩余的字符数； 
    	   countfield.value = maxlimit - field.value.length; 
    	   }  

    	
    </script>
</head>
<body>   
<form id="inputForm" name="inputForm">
<!-- 创建编辑头部 -->
<c:if test="${duty.editFlag == 1}">
<div id="createHead" class="layerHeader clearfix">
	<c:choose>
	   <c:when test="${duty.dutyID!=null && duty.dutyID!=''}">
	    <!-- 编辑 --> 
			<p class="headerTitle"><spring:message code="duty_edit_edit"/></p>
       </c:when>
       <c:otherwise>
        <!-- 创建 --> 
            <p class="headerTitle"><spring:message code="duty_edit_create"/></p>
       </c:otherwise>
    </c:choose>
    <div class="headerButton clearfix">
        <!-- 确认 -->      
       	<button type="button" id="okButton" ><spring:message code="duty_edit_ok"/></button>
        <!-- 取消 -->
        <button type="button" onclick="closeWin()"><spring:message code="duty_edit_cancle"/></button>
    </div>
</div>
<!-- 确认画面头部 -->
<div id="okHead" class="layerHeader clearfix" style="display: none;">	      
             <p class="headerTitle"><spring:message code="duty_edit_ok" /></p>    
    <div class="headerButton clearfix">
    <shiro:hasPermission name="business:install:edit">
    <c:choose>
	   <c:when test="${duty.dutyID!=null && duty.dutyID!=''}">
	    <!-- 编辑 保存 --> 
			<button type="button" onclick="saveForm()"><spring:message code="common_save" /></button>
       </c:when>
       <c:otherwise>
        <!-- 创建 保存 --> 
            <button type="button" onclick="saveForm()"><spring:message code="common_save" /></button>
       </c:otherwise>
     </c:choose>
     </shiro:hasPermission>   
          
        <!-- 取消 -->
          <button type="button" onclick="closeWin()"><spring:message code="duty_edit_cancle"/></button>
    </div>
</div>
</c:if>
 <!-- 查看画面头部 -->
<c:if test="${duty.editFlag == 0}">
<div id="viewHead" class="layerHeader clearfix" >
          <p class="headerTitle"><spring:message code="duty_edit_view" /></p>
    <div class="headerButton clearfix">
    	<shiro:hasPermission name="business:install:view">
        <!-- 编辑  -->
          <button type="button" onclick="popup('800px','519px','${ctx}/business/install/editDuty?dutyID=${duty.dutyID}&editFlag=1');closeWin()">
               	<spring:message code="duty_edit_edit" />
          </button>
         </shiro:hasPermission>
         <shiro:hasPermission name="business:install:edit">
          <!-- 删除  -->
          <button type="button" onclick="deleteDuty();">
               	<spring:message code="duty_edit_delete" />
          </button>
          </shiro:hasPermission>
        <!-- 取消 -->
          <button type="button" onclick="closeWin()"><spring:message code="duty_edit_cancle"/></button>
    </div>
</div>
</c:if>

<!-- 入力框 -->

<div id="showHtml" class="tabBoxSm <c:if test="${duty.editFlag == 0}">showHtml</c:if>">
    <div class="tabSm smOrderBox">
        <div class="clearfix">
    	<input type="hidden" id="createDate" name="createDate" value="${fns:getDate('yyyy-MM-dd HH:mm')}">
    	<input type="hidden" id="createID" name="createID" value="${fns:getUser()}">
    	<input type="hidden" id="dutyID" name="dutyID" value="${duty.dutyID}">
    	<input type="hidden" id="version" name="version" value="${duty.version}">
        <input type="hidden" id="editFlag" name="editFlag" value="${duty.editFlag}">
               <!--  职务名称 -->
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="duty_edit_name"/></p>
                    <input id="dutyName" name="dutyName" maxlength="50" value="${duty.dutyName}" data-rule-required="true" data-msg-required="<spring:message code="duty_edit_err_msg_dutyName"/>">
                    <p class="haveTo">*</p>
                </div>
                
                <!--  状态 -->
                <div class="items clearfix">
                  <p class="tit"><spring:message code="duty_edit_status"/></p>
                	<c:if test="${duty.editFlag == 1}">
                           <div class="labelBox">
                           <label>
                                 <p><input type="radio" style="width:30px;" id="yes" name="dutyStatus" value="1"  <c:if test="${duty.dutyStatus eq 1 ||duty.dutyStatus eq null}"> checked="checked"</c:if>>
                                 <spring:message code="duty_edit_open"/></p>
                           </label>
                           <label>
                                 <p><input type="radio" style="width:30px;" id="no" name="dutyStatus" value="0"  <c:if test="${duty.dutyStatus eq 0}"> checked="checked"</c:if>>
                                 <spring:message code="duty_edit_close"/></p>
                                 </label>
                           </div>
                    </c:if>
                    <c:if test="${duty.editFlag == 0}">
                    <c:if test="${duty.dutyStatus eq 0}">
                    <p class="tit"><spring:message code="duty_edit_close"/></p>
                    </c:if>
                    <c:if test="${duty.dutyStatus eq 1}">
                    <p class="tit"><spring:message code="duty_edit_open"/></p>
                    </c:if>
                    </c:if>
                </div>
            
            
               <!--  职务描述-->
               <div class="items clearfix">
                	<p class=" tit"><spring:message code="duty_edit_describe"/></p>
                    <textarea name="dutyDescribe" cols="28" rows="5" style="width: 300px;height: 150px;" onKeyDown="textCounter(dutyDescribe,remLen,100);" onKeyUp="textCounter(dutyDescribe,remLen,100);">${duty.dutyDescribe}</textarea>
                 <div id="numCount" class="items" style="margin-left: 60px">
                  <c:if test="${duty.editFlag == 1}">
        			<input name="remLen" type="text" value="100" style="width: 24px;color: #333;border: none;background-color: inherit" disabled="true ">/100
        		  </c:if>
        		 </div>
               </div>
           
       
        </div> 
	</div>
</div>
</form>
<script>
</script>
</body>
</html>
